#include "cpu/exec/helper.h"

make_helper(ret) {
    uint32_t address = swaddr_read(reg_l(R_ESP), 4);
    reg_l(R_ESP) += 4;
    cpu.eip = address - 1;
    print_asm("ret");
    return 1;
}

make_helper(ret_si) {
    uint32_t address = swaddr_read(reg_l(R_ESP), 4);
    reg_l(R_ESP) += 4;
    int len = decode_si_w(eip + 1);
    cpu.eip = address - 1 - len;
    print_asm("ret");
    reg_l(R_ESP) += op_src->val;
    return len + 1;
}